package pierwszy.testNGexcercises;

import java.lang.reflect.Method;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Parameters;



public class TestNGexercises {
		
	@BeforeSuite (alwaysRun = true)
	void bS(){
		System.out.println("Before suite.");
	}
	
	@AfterSuite (alwaysRun = true)
	public void aS(){
		System.out.println("After suite.");
	}
	
	@BeforeTest(alwaysRun = true)
	public void bT(){
		System.out.println("Before test.");
	}
	
	@AfterTest (alwaysRun = true)
	public void aT(){
		System.out.println("After test.");
	}
	
	@BeforeGroups (alwaysRun = true)
	public void bG(){
		System.out.println("Before groups.");
	}
	
	@AfterGroups (alwaysRun = true)
	public void aG(){
		System.out.println("After groups.");
	}
	
	@BeforeClass (alwaysRun = true)
	public void bC(){
		System.out.println("Before class.");
	}
	
	@AfterClass (alwaysRun = true)
	public void aC(){
		System.out.println("After class.");
	}
	
	@BeforeMethod (alwaysRun = true)
	public void bM(Method m){
		System.out.println("Before method." + m.getName());
	}
	
	@AfterMethod (alwaysRun = true)
	public void aM(Method m){
		System.out.println("After method." +  m.getName());
	}
	
	
	@DataProvider (name = "dataProvider")
	public Object[][] dp(){
		return new Object[][]{
				{"test dp1"},
				{"test dp2"}
		};
	}
	
	
	@Test(groups = "groupA", dataProvider="dataProvider")
	public void test1(String dp){
		System.out.println("Test 1. " + dp);
	}
	
	@Parameters({"tp"})
	@Test (groups = "groupB")
	public void test2(String testParameter){
		System.out.println("Test 2. " + testParameter);
	}
	
	@Test (groups = "groupA")
	public void test3(){
		System.out.println("Test 3.");
	}

}
